import fileModel
import numpy as np
from scipy.sparse import *


def read_data_for_mmatrix(data_path, tag_path):
    tag = fileModel.read_one_line_data(tag_path)
    np_tag = np.ndarray(len(tag))
    tag_map = {}
    for index,item in enumerate(tag):
        if item not in tag_map:
            tag_map[item] = len(tag_map)+1
        np_tag[index] = tag_map[item]
    data = csr_matrix(fileModel.read_float_data(data_path))
    return data, np_tag

